package com.pphh.demo;

/**
 * memory leak demo with int bytes creation
 * <p>
 * test command :
 * java -Xms8m -Xmx8m -Xmn4m -classpath "./target/classes" com.pphh.demo.DemoIntArrayCreation
 * <p>
 * if change "-Xmx8m" to be "-Xmx9m", the demo application will run successfully
 *
 * @author huangyinhuang
 * @date 8/23/2018
 */
public class DemoIntArrayCreation {

    static final int SIZE = 1024 * 1024;

    public static void main(String[] args) {
        System.out.println("try to create a int array with size of " + SIZE);
        try {
            int[] i = new int[SIZE];
            System.out.println("Success!");
        } catch (Exception e) {
            System.out.println("Failed!");
            e.printStackTrace();
        }
    }

}
